package com.netposa.datawarehouse.aggregator.web.rest;

import com.netposa.appwebres.WebResCallback;
import com.netposa.appwebres.common.WebResCriteria;
import com.netposa.appwebres.common.WebResInfo;
import com.netposa.datawarehouse.aggregator.service.AggregatorCommonService;
import com.netposa.vdt.pccclient.autoconfigure.StructureTaskConfigProperties;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"common"})
public class CommonController {
   @Autowired
   private StructureTaskConfigProperties properties;
   @Autowired
   private AggregatorCommonService service;

   @RequestMapping({"structure_type"})
   public WebResInfo structureType() {
      return (new WebResCallback() {
         public void execute(WebResCriteria criteria, Object... params) {
            Map map = new HashMap();
            map.put("face", "PCC");
            map.put("body", CommonController.this.properties.getStructureBodyType());
            map.put("vehicle", CommonController.this.properties.getStructureVehicleType());
            map.put("nonmotor", CommonController.this.properties.getStructureVehicleType());
            criteria.addSingleResult(map);
         }
      }).sendRequest(new Object[0]);
   }

   @GetMapping({"/imageToBase64"})
   public WebResInfo imageToBase64(@RequestParam("img") final String img) {
      return (new WebResCallback() {
         public void execute(WebResCriteria webResCriteria, Object... objects) {
            webResCriteria.addSingleResult(CommonController.this.service.imgToBase64(img));
         }
      }).sendRequest(new Object[0]);
   }
}
